package priv.happy.mealpickpro.util;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.mail.MailProperties;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Component;

/**
 * @Author: HAPPY
 * @Project_name: recruitSystem
 * @Package_name: grad.nxu.recruitsystem.util
 * @Date: 2023/3/12 0:05
 * @Description:
 */

@Component
public class EmailUtil {
    @Autowired
    MailProperties mailProperties;
    @Autowired
    private JavaMailSender sender;

    /**
     * 发送邮件
     *
     * @param to      收件人邮箱
     * @param subject 邮件主题
     * @param content 邮件内容
     */
    public void sendEmail(String to, String subject, String content) {
        SimpleMailMessage message = new SimpleMailMessage();
        message.setFrom(mailProperties.getUsername());
        message.setTo(to);
        message.setSubject(subject);
        message.setText(content);
        sender.send(message);
    }

}
